package memento;

public class Originator {
    private  String version;

    private String creator;

    private Long createTime;

    public Originator() {
    }

    public Originator(String version, String creator, Long createTime) {
        this.version = version;
        this.creator = creator;
        this.createTime = createTime;
    }

    //创建版本
    public Memento createMemento(){
        return new Memento(version,creator,createTime);
    }

    //回退版本
    public void restoreMemento(Memento memento){
        this.version = memento.getVersion();
        this.createTime = memento.getCreateTime();
        this.creator = memento.getCreator();
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "版本：'" + version + '\'' +
                ", 创建者：'" + creator + '\'' +
                ", 创建时间戳：" + createTime ;
    }
}
